package com.roamer.audition.web.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.annotations.ApiIgnore;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger2 配置
 *
 * @author roamer
 * @version V1.0
 * @date 2019/9/1 3:45 下午
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                                                      .select()
                                                      .apis(RequestHandlerSelectors.basePackage(
                                                              "com.roamer.audition.web.controller"))
                                                      .paths(PathSelectors.any())
                                                      .build()
                                                      .ignoredParameterTypes(ApiIgnore.class);
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("Audition Plan Application RESTful API")
                                   .description("面试计划")
                                   .termsOfServiceUrl("http://localhost:80")
                                   .contact(new Contact("roamer", null, "592146505@qq.com"))
                                   .version("1.0")
                                   .build();
    }


}
